package com.example.zhc36.fragment.utils.db;

/*
 classpath "io.realm:realm-gradle-plugin:5.4.1"

 apply plugin: 'realm-android'

// 主要内容封装进各自Dao中

 */

import android.app.Application;


import com.example.zhc36.fragment.bean.Featurebean;
import com.example.zhc36.fragment.utils.app.AppContent;

import io.realm.Realm;
import io.realm.RealmConfiguration;

public class DbHelper {

    public static void init(Application app) {
        Realm.init(app);
        RealmConfiguration config = new RealmConfiguration.Builder()
                .schemaVersion(1)
                .name(AppContent.APP_NAME)
//                .directory()
                .deleteRealmIfMigrationNeeded()
                .initialData(new Realm.Transaction() {
                    @Override
                    public void execute(Realm realm) {

                        realm.insert(new Featurebean(1, "好友微视", null, "1"));
                        realm.insert(new Featurebean(2, "同城服务", null, "1"));
                        realm.insert(new Featurebean(3, "游戏", null, "1"));
                        realm.insert(new Featurebean(4, "看点", null, "1"));
                        realm.insert(new Featurebean(5, "京东购物", null, "1"));
                        realm.insert(new Featurebean(6, "企鹅电竞", null, "0"));
                        realm.insert(new Featurebean(7, "鹅漫U品", null, "0"));
                        realm.insert(new Featurebean(8, "动漫", null, "0"));
                        realm.insert(new Featurebean(9, "阅读", null, "0"));
                        realm.insert(new Featurebean(10, "音乐", null, "0"));
                        realm.insert(new Featurebean(11, "直播", null, "0"));
                        realm.insert(new Featurebean(12, "运动", null, "0"));
                        realm.insert(new Featurebean(13, "吃喝玩乐", null, "0"));
                        realm.insert(new Featurebean(14, "腾讯新闻", null, "0"));
                        realm.insert(new Featurebean(15, "腾讯课堂", null, "0"));
                    }
                })
                .build();
        Realm.setDefaultConfiguration(config);
    }


}
